using System;
using System.Collections.Generic;

namespace PeDALS.Tools.AZ.PSTArchive.PSTData
{
    internal class FolderStats
    {
        private UInt64 m64NIDraw;
        private string mstrName;
        private string mstrPath;
        private int mintContentCount;
        private int mintHiddenCount;
        private bool mbSubfoldersExist;
        private SortedList<UInt64, FolderStats> mslfsSubfolders = new SortedList<UInt64, FolderStats>();
        private SortedList<UInt64, FolderStats> mslfsEmptySubfolders = new SortedList<UInt64, FolderStats>();
        private SortedList<UInt64, MessageStats> mslmsMessages = new SortedList<UInt64, MessageStats>();

        internal FolderStats (UInt64 u64NIDraw, string strName, string strPath, int intContentCount, int intHiddenCount, bool bSubfoldersExist)
        {
            m64NIDraw = u64NIDraw;
            mstrName = strName;
            mstrPath = strPath;
            mintContentCount = intContentCount;
            mintHiddenCount = intHiddenCount;
            mbSubfoldersExist = bSubfoldersExist;
        }

        internal UInt64 NIDraw
        {
            get { return m64NIDraw; }
        }

        internal NIDTypes NIDType
        {
            get { return (NIDTypes)(m64NIDraw & 0x1f); }
        }
	
        internal string Name
        {
            get { return mstrName; }
        }

        internal string Path
        {
            get { return mstrPath; }
        }
	
        internal int ContentCount
        {
            get { return mintContentCount; }
        }
	
        internal int HiddenCount
        {
            get { return mintHiddenCount; }
        }
	
        internal bool SubfoldersExist
        {
            get { return mbSubfoldersExist; }
        }

        internal bool OnlyNormalSubfolders
        {
            get
            {
                bool blnReturn = true;
                foreach (FolderStats fsFolder in mslfsSubfolders.Values)
                {
                    if (fsFolder.NIDType != NIDTypes.NormalFolder) blnReturn = false;
                    if (!blnReturn) break;
                }
                if (blnReturn)
                {
                    foreach (FolderStats fsFolder in mslfsEmptySubfolders.Values)
                    {
                        if (fsFolder.NIDType != NIDTypes.NormalFolder) blnReturn = false;
                        if (!blnReturn) break;
                    }
                }
                return blnReturn;
            }
        }

        internal bool MessageCountsMatch
        {
            get { return (mslmsMessages.Count == mintContentCount + mintHiddenCount); }
        }
	
        internal SortedList<UInt64, FolderStats> Subfolders
        {
            get { return mslfsSubfolders; }
        }

        internal SortedList<UInt64, FolderStats> EmptySubfolders
        {
            get { return mslfsEmptySubfolders; }
        }

        internal SortedList<UInt64, MessageStats> Messages
        {
            get { return mslmsMessages; }
        }
    }
}